package cn.chenc.framework.mail.config;

import cn.chenc.framework.mail.core.MailTemplate;
import cn.chenc.framework.mail.core.SecretMailTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.mail.MailProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.javamail.JavaMailSender;

/**
 * 　@description: 邮件配置
 * 　@author secret
 * 　@date 2021/6/5 21:49
 *
 */
@Configuration
public class MailConfiguration {

    @Autowired
    private JavaMailSender mailSender;

    @Autowired
    private MailProperties mailProperties;

    @Bean
    @ConditionalOnClass({MailProperties.class, JavaMailSender.class})
    public MailTemplate mailTemplate() {
        return new SecretMailTemplate(mailSender,mailProperties);
    }

}
